{{ template "base" . }}

{{ define "title" }}文章管理{{ end }}

{{ define "content" }}
    <div class="admin-header">
        <div>
            <h2>文章管理</h2>
            <p>欢迎, {{ .username }} | <a href="/admin/logout">退出</a></p>
        </div>
        <a href="/admin/article/new" class="btn">新建文章</a>
    </div>
    
    <table class="article-table">
        <thead>
            <tr>
                <th>标题</th>
                <th>状态</th>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {{ range .articles }}
            <tr>
                <td>{{ .Title }}</td>
                <td>
                    {{ if .Published }}
                    <span class="published">已发布</span>
                    {{ else }}
                    <span class="draft">草稿</span>
                    {{ end }}
                </td>
                <td>{{ .CreatedAt.Format "2006-01-02" }}</td>
                <td>
                    <a href="/admin/article/{{ .ID }}" class="btn btn-small">编辑</a>
                    <a href="/admin/article/delete/{{ .ID }}" class="btn btn-small btn-danger">删除</a>
                </td>
            </tr>
            {{ else }}
            <tr>
                <td colspan="4">暂无文章</td>
            </tr>
            {{ end }}
        </tbody>
    </table>
{{ end }}